package com.genesis.yunnanji.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.genesis.yunnanji.R;
import com.genesis.yunnanji.activity.PavilionMain;
import com.genesis.yunnanji.bean.PavilionBean;
import com.genesis.yunnanji.config.GenesisApiConfig;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.BitmapDisplayConfig;

import java.util.List;

/**
 * Created by Administrator on 2017/11/13.
 */

public class PavilionAdapter extends BaseQuickAdapter<PavilionBean.ResultBean.ListBean, BaseViewHolder> {
    private Context context;

    public PavilionAdapter(Context context, @Nullable List<PavilionBean.ResultBean.ListBean> data) {
        super(R.layout.layout_pavilion_item, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final PavilionBean.ResultBean.ListBean item) {
        BitmapUtils bitmapUtils = new BitmapUtils(context);
        BitmapDisplayConfig displayConfig = new BitmapDisplayConfig();
        displayConfig.setLoadingDrawable(context.getResources().getDrawable(R.mipmap.default_state));
        bitmapUtils.display(helper.getView(R.id.iv_pavilionitem_img), GenesisApiConfig.PIC_HOST + item.getApp_img(), displayConfig);
        helper.getView(R.id.iv_pavilionitem_img).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, PavilionMain.class);
                intent.putExtra("pavilion_id", item.getId());
                context.startActivity(intent);
            }
        });
    }
}
